package com.freely.domain;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.validation.constraints.Pattern;

import org.hibernate.validator.constraints.Length;

/**
group_id	bigint	primary key	not null	群id
group_admin	bigint	foreign key	not null	群主id
group_account	varchar(10)		not null	群帐号
group_name	varchar(16)		not null	群名称
group_sum	int		not null	群人数
group_image	varchar(60)		not null	群头像
group_create_date	Timestamp		not null	群创建日期
group_notice	varchar(100)			群公告
group_forbidden	bool		not null	是否禁用

 * @author Administrator
 *
 */
public class Group {
	private Long group_id;								// 群id
	@Pattern(regexp="\\d{10}",message="帐号格式错误，格式为10个数字")
	private String group_account;						// 群帐号
	@Length(min=1,max=20,message="群名长度不能超过20")
	private String group_name;							// 群名称
	private Integer group_sum;							// 群人数
	private String group_image;							// 群头像
	private Date group_create_date;						// 群创建日期
	@Length(min=0,max=100,message="公告长度不能超过100")
	private String group_notice;						// 群公告
	private Boolean group_forbidden;					// 是否禁用
	private User group_admin;							// 群主
	private Set<User> users = new HashSet<>();			// 群员
	
	public Long getGroup_id() {
		return group_id;
	}
	public void setGroup_id(Long group_id) {
		this.group_id = group_id;
	}
	public String getGroup_account() {
		return group_account;
	}
	public void setGroup_account(String group_account) {
		this.group_account = group_account;
	}
	public String getGroup_name() {
		return group_name;
	}
	public void setGroup_name(String group_name) {
		this.group_name = group_name;
	}
	public Integer getGroup_sum() {
		return group_sum;
	}
	public void setGroup_sum(Integer group_sum) {
		this.group_sum = group_sum;
	}
	public String getGroup_image() {
		return group_image;
	}
	public void setGroup_image(String group_image) {
		this.group_image = group_image;
	}
	public Date getGroup_create_date() {
		return group_create_date;
	}
	public void setGroup_create_date(Date group_create_date) {
		this.group_create_date = group_create_date;
	}
	public String getGroup_notice() {
		return group_notice;
	}
	public void setGroup_notice(String group_notice) {
		this.group_notice = group_notice;
	}
	public Boolean getGroup_forbidden() {
		return group_forbidden;
	}
	public void setGroup_forbidden(Boolean group_forbidden) {
		this.group_forbidden = group_forbidden;
	}
	public User getGroup_admin() {
		return group_admin;
	}
	public void setGroup_admin(User group_admin) {
		this.group_admin = group_admin;
	}
	public Set<User> getUsers() {
		return users;
	}
	public void setUsers(Set<User> users) {
		this.users = users;
	}
	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();
		sb.append("Group [group_id=" + group_id + ", group_account=" + group_account + ", group_name=" + group_name
				+ ", group_sum=" + group_sum + ", group_image=" + group_image + ", group_create_date="
				+ group_create_date + ", group_notice=" + group_notice + ", group_forbidden=" + group_forbidden
				+ ", group_admin=" + group_admin + "]");
		if(users.size() <= 0) {
			sb.append(" users is empty");
		}else {
			sb.append(" users : ");
			for(User temp : users) {
				sb.append(temp.getUser_name() + " , ");
			}
		}
		return sb.toString();
	}
	
}
